
#include <stdio.h>
#include <stdint.h>

#include "common/alloc.h"

typedef uint8_t         FileChar;
typedef uint8_t         FileTypeCode;
typedef uint32_t        FileInt;
typedef uint32_t        FileOffset;

#define MAX_HINT_CITIES (10)

#pragma pack(push, 1)

/**
 * contains hint cities sorted by population that corresponds to the entered
 * text given
 */
struct FileHintCityNodesArray
{
    /**
     * size is an integer that is greater than zero,
     * it defines length of the city_node_offset array
     */
    FileInt             size;

    /**
     * offsets to FileCityNode(s)
     */
    FileOffset          city_node_offsets[1];
};

struct FileEntry
{
    /**
     * character, associated with a node given
     */
    FileChar            node_char;

    /**
     * offset of the node with this character
     */
    FileOffset          node_offset;

    /**
     * zero - for non-cities related path
     * non-zero - for offset to the corresponding FileHintCityNodesArray
     * instance
     */
    FileOffset          hint_city_nodes_array;
};

/**
 * header of the node, it defines the kind of a subsequent node
 */
struct FileNodeHeader
{
    FileTypeCode        node_type;
    FileOffset          parent_node_offset;
};

struct FileNonLeafNode
{
    FileInt             entries_count;
    struct FileEntry    entries[1];
};

struct FileAliasCityNode
{
    FileInt             entries;
    FileOffset          unique_cities[1];
};

struct FileUniqueCityNode
{
    FileInt             population;
    FileInt             code;
};

struct FileCountryNode
{
    FileInt             code;
};

/**
 * node types
 */
enum
{
    FILE_NODE_TYPE_NONLEAF,
    FILE_NODE_TYPE_CITY,
    FILE_NODE_TYPE_STATE,
};

#pragma pack(pop)


static void test1()
{
    size_t buf_size = 65536;
    uint8_t * buf = xmalloc(buf_size);

    xfree(buf);
}

//static void ent_data


void test_tree1_0()
{
    FILE * f = fopen("tmp-nodes", "rb");
    if (f != NULL)
    {
    }


    if (f != NULL)
    {
        fclose(f);
    }
}


struct Node;

struct Ent
{
    int nodes_cnt;
    struct Node * nodes;
};

struct Node
{
    int type;
};

void test_tree1()
{
    test1();
}
